package com.pingan.haofang.searchcloud.web.metadata.form;

import com.pingan.haofang.searchcloud.api.matedata.constant.MetadataFieldType;
import com.pingan.haofang.searchcloud.common.constants.Constants;
import com.pingan.haofang.searchcloud.common.validator.annotation.EnumOption;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * 保存索引字段form
 * @author baojie371
 * @date 17/5/4
 * @since 1.0.0
 */
@ApiModel(description = "保存索引字段form")
public class MetadataFieldForm {

    @NotNull(message = "metadata.field.fieldName.illegal")
    @Length(min = 2, max = 32, message = "metadata.field.fieldName.illegal")
    @Pattern(regexp = Constants.NAME_PATTERN, message = "common.name.pattern.error")
    @ApiModelProperty(value = "字段名称", required = true)
    private String fieldName;

    @NotNull(message = "metadata.field.fieldTypeId.illegal")
    @EnumOption(enumClass = MetadataFieldType.class, message = "metadata.field.fieldTypeId.illegal")
    @ApiModelProperty(value = "字段类型ID", allowableValues = "range[1,infinity]", required = true)
    private Integer fieldTypeId;

    @Length(max = 32, message = "metadata.field.fieldComment.illegal")
    @ApiModelProperty(value = "字段别名", required = false)
    private String fieldComment;

    @NotNull(message = "metadata.field.uniqueKey.illegal")
    @ApiModelProperty(value = "是否唯一", required = true)
    private Boolean uniqueKey;

    @NotNull(message = "metadata.field.uniqueKey.illegal")
    @ApiModelProperty(value = "是否是数据版本号字段", required = true)
    private Boolean versionKey;

    @NotNull(message = "metadata.field.required.illegal")
    @ApiModelProperty(value = "是否必填", required = true)
    private Boolean required;

    @NotNull(message = "metadata.field.indexed.illegal")
    @ApiModelProperty(value = "是否索引", required = true)
    private Boolean indexed;

    @NotNull(message = "metadata.field.stored.illegal")
    @ApiModelProperty(value = "是否可存储", required = true)
    private Boolean stored;

    @NotNull(message = "metadata.field.termVectors.illegal")
    @ApiModelProperty(value = "是否可向量", required = true)
    private Boolean termVectors;

    @NotNull(message = "metadata.field.multiValued.illegal")
    @ApiModelProperty(value = "是否可多值", required = true)
    private Boolean multiValued;

    @Length(max = 100, message = "metadata.field.defaultValue.illegal")
    @ApiModelProperty(value = "默认值", required = false)
    private String defaultValue;

    @Length(max = 500, message = "metadata.field.copyToField.illegal")
    @ApiModelProperty(value = "复制到字段，多个逗号分隔", required = false)
    private String copyToField;

    @Range(min = 0, message = "metadata.field.boost.illegal")
    @ApiModelProperty(value = "权重，扩大100倍", required = false)
    private Long boost;

    public Boolean getVersionKey() {
        return versionKey;
    }

    public void setVersionKey(Boolean versionKey) {
        this.versionKey = versionKey;
    }

    public String getFieldName() {
        return fieldName;
    }

    public void setFieldName(String fieldName) {
        this.fieldName = fieldName;
    }

    public Integer getFieldTypeId() {
        return fieldTypeId;
    }

    public void setFieldTypeId(Integer fieldTypeId) {
        this.fieldTypeId = fieldTypeId;
    }

    public String getFieldComment() {
        return fieldComment;
    }

    public void setFieldComment(String fieldComment) {
        this.fieldComment = fieldComment;
    }

    public Boolean getUniqueKey() {
        return uniqueKey;
    }

    public void setUniqueKey(Boolean uniqueKey) {
        this.uniqueKey = uniqueKey;
    }

    public Boolean getRequired() {
        return required;
    }

    public void setRequired(Boolean required) {
        this.required = required;
    }

    public Boolean getIndexed() {
        return indexed;
    }

    public void setIndexed(Boolean indexed) {
        this.indexed = indexed;
    }

    public Boolean getStored() {
        return stored;
    }

    public void setStored(Boolean stored) {
        this.stored = stored;
    }

    public Boolean getTermVectors() {
        return termVectors;
    }

    public void setTermVectors(Boolean termVectors) {
        this.termVectors = termVectors;
    }

    public Boolean getMultiValued() {
        return multiValued;
    }

    public void setMultiValued(Boolean multiValued) {
        this.multiValued = multiValued;
    }

    public String getDefaultValue() {
        return defaultValue;
    }

    public void setDefaultValue(String defaultValue) {
        this.defaultValue = defaultValue;
    }

    public String getCopyToField() {
        return copyToField;
    }

    public void setCopyToField(String copyToField) {
        this.copyToField = copyToField;
    }

    public Long getBoost() {
        return boost;
    }

    public void setBoost(Long boost) {
        this.boost = boost;
    }
}
